<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增工单表')"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-form-add">
        <div class="form-group">
            <label class="col-sm-3 control-label">持有者：</label>
            <div class="col-sm-8">
                <input id="liveForeighn"  th:text="${holeName}" hidden>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label">工单描述：</label>
            <div class="col-sm-8">
                <input id="id" th:value="${id}" hidden>
                <input id="toolbarss" name="completeDescription" class="form-control" type="text" multiple  >
            </div>
        </div>
    </form>
    <!--<div class="wrapper wrapper-content animated fadeInRight" th:width="300px">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <div class="form-group">
                            <label class="font-noraml">文件上传</label>
                            <div class="file-loading">
                                <input id="fileinput-demo-1" name="file" type="file" multiple>
                            </div>
                        </div>
                        <hr>
                    </div>
                </div>
            </div>
        </div>
    </div>-->
    <div class="form-group">
        <label class="col-sm-3 control-label">上传</label>
        <div class="col-sm-8">
            <input id="filePath" name="filePath" class="form-control" type="file">
        </div>
    </div>
    <div class="form-group">
        <label class="col-sm-3 control-label"></label>
        <div class="col-sm-8">
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="submitok()">
                    <i class="fa fa-plus"></i> 确定
                </a>
                <a class="btn btn-primary single" onclick="closeTab()">
                    <i class="fa fa-edit"></i> 取消
                </a>

                </a>

            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<script type="text/javascript">
    var prefix = ctx + "system/pend"
    $("#form-form-add").validate({
        focusCleanup: true
    });

    /* $(document).ready(function () {
         $("#fileinput-demo-1").fileinput({
             'theme': 'explorer-fas',
             'uploadUrl': prefix+"/uploadTo",
             overwriteInitial: false,
             initialPreviewAsData: true,
             initialPreview: [

             ]
         });
     });*/
    function closeTab() {

        $.modal.closeTab()
    }

    function submitok() {
        var formData = new FormData();

        /*var t = $('#liveForeighn').val();
        var f = $('#toolbarss').val();
        var t = $('#username').val();*/

        if ($('#filePath')[0].files[0] == null) {
            $.modal.alertWarning("请先选择文件路径");
            return false;
        }
        formData.append('description', $('#toolbarss').val());
        formData.append('id', $('#id').val());
        formData.append('file', $('#filePath')[0].files[0]);

        //$.operate.submit(prefix + "/addFrom", "post", "json", formData)
        $.ajax({
            url: prefix + "/finishFrom",
            type: 'post',
            cache: false,
            data: formData,
            processData: false,
            contentType: false,
            dataType: "json",
            success: function (result) {
                $.operate.successCallback(result);
            }
        });
        window.parent.location.reload();
        $.modal.closeTab()
    }
</script>
</body>
</html>